
package client.controller;

import client.GUI.GuiFrame;
import client.model.ClientListener;
import com.esotericsoftware.kryonet.Client;
import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.Listener;
import java.io.IOException;

public class ClientController {
    public static int PORT_TCP = 6000;
    public static int PORT_UDP;
    public static int TIME_OUT=5000;
    public static String HOST_ADRESS="192.227.166.97";
    public static int CONNECTION_TYPE; /* 1= TCP, 2= UDP */
    
    
    Client client;
    GuiFrame gui;
    
    public ClientController () {
        gui = new GuiFrame();
        
        client = new Client();
        client.start();
        
        network.ClassRegister.register(client);
        
        client.addListener(new ClientListener(gui));
       
        //client.setKeepAliveTCP(1000);
    }
    
    public Client getClient(){
        return client;
    }
    
    public GuiFrame getGUI() {
        return gui;
    }
    public void test_connectToHost  () throws IOException {
        client.connect(TIME_OUT, HOST_ADRESS, PORT_TCP);
    }
    
    public void test_sendSomething () {
        network.data.request.GotowyNaStart za = new network.data.request.GotowyNaStart();
        client.sendTCP(za);
        System.out.println("Client> sent something on test");
    }
    
}
